/**
* @Author: jianglei
* @Date:   2017-10-12 12:06:49
*/
'use strict'
  
  /**
   * @description 树形结构数据转换成父子关系的数组
   * @param data
   * @returns {[]}
   */
  export default function translateTreeToData(list) {
    let data = JSON.parse(JSON.stringify(list))
    const result = []
    data.forEach((item) => {
      const loop = (data) => {
        const child = data.children
        if (child) {
          for (let i = 0; i < child.length; i++) {
            loop(child[i])
          }
          delete data.children
        }
        result.push(data)
      }
      loop(item)
    })
    return result
  }
 
